﻿<UserControl x:Class="Boggle.Net.Views.GameView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:Controls="clr-namespace:Boggle.Net.Controls"
        >

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Styles\Styles.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <!--<Converters:TrayPathToStringConverter x:Key="TrayPathToStringConverter" />-->

            <Controls:AutoGrayableImage x:Key="OK" Source="../Assets/accept.png" />
            <Controls:AutoGrayableImage x:Key="Cancel" Source="../Assets/cancel.png" />

            <Style x:Key="WordListStyle" TargetType="{x:Type DataGrid}">
                <Setter Property="AlternationCount" Value="2" />
                <Setter Property="AutoGenerateColumns" Value="False" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="CanUserReorderColumns" Value="False" />
                <Setter Property="ColumnWidth" Value="*" />
                <Setter Property="GridLinesVisibility" Value="None" />
                <Setter Property="IsReadOnly" Value="True" />
                <Setter Property="RowHeaderWidth" Value="0" />
                <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Visible" />
                <Setter Property="SelectionMode" Value="Single" />
            </Style>

            <Style x:Key="FoundWordStyle" TargetType="{x:Type DataGridCell}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding WasFound}" Value="true">
                        <Setter Property="Foreground" Value="Green"/>
                        <Setter Property="FontWeight" Value="Bold"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="ScoreStyle" TargetType="{x:Type TextBlock}">
                <Setter Property="HorizontalAlignment" Value="Right" />
            </Style>

        </ResourceDictionary>
    </UserControl.Resources>
    <DockPanel>
        
        <!-- Search Results -->
        <Border DockPanel.Dock="Right" Width="160" BorderThickness="3,0,0,0" BorderBrush="{StaticResource BackgroundBrush}">
            <DataGrid x:Name="PathList" 
                ItemsSource="{Binding WordList}" 
                SelectedItem="{Binding Tray.TracedPlay}"
                Style="{StaticResource WordListStyle}">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Word" Binding="{Binding Word}" CellStyle="{StaticResource FoundWordStyle}" Width="2*" />
                    <DataGridTextColumn Header="Score" Binding="{Binding Score}" ElementStyle="{StaticResource ScoreStyle}" />
                    <!--<DataGridTextColumn Header="Path" Binding="{Binding Path, Converter={StaticResource TrayPathToStringConverter}}" Width="5*" CanUserSort="False" />-->
                </DataGrid.Columns>
            </DataGrid>
        </Border>

        <!-- Tray -->
        <Border SnapsToDevicePixels="True">
            <StackPanel VerticalAlignment="Center" Width="200">
                
                <!-- Input Area -->
                <Border Padding="2" BorderThickness="1" BorderBrush="{StaticResource BackgroundBrush}" Margin="2,0,2,4">
                    <DockPanel>
                        <StackPanel Orientation="Horizontal" DockPanel.Dock="Right">
                            <StackPanel.Resources>
                                <Style TargetType="{x:Type Button}">
                                    <Setter Property="Margin" Value="2,0,0,0" />
                                </Style>
                            </StackPanel.Resources>
                            <Button x:Name="AddSelection" DockPanel.Dock="Right" Content="{StaticResource OK}" />
                            <Button x:Name="ClearSelection" Content="{StaticResource Cancel}" />
                        </StackPanel>

                        <TextBlock Text="{Binding Tray.SelectedWord}" VerticalAlignment="Center" FontSize="18" />
                    </DockPanel>
                </Border>
                
                <ContentControl x:Name="Tray" />
            </StackPanel>
        </Border>
    </DockPanel>
</UserControl>
